<!DOCTYPE html>
<html>
  <head>
    <script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
    <title>123123123</title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <style >
      a,button {
        display:block;
        color: #00B7FF;
        margin-top: 20px;
      }
    </style>

    <script src="/javascripts/jds-sdk.js"></script>
    <script>
      document.write("test="+window.test)
    </script>
    <title>test</title>
  </head>
  
  <body>
    <h1></h1>
    <button onclick="invokeTest()" >测试方法调用</button><br/>
    <button onclick="invokeShareWeb1()" >分享网页1</button><br/>
    <button onclick="invokeShareWeb2()" >分享网页2</button><br/>
    <button onclick="invokeShareImage1()" >分享图片3</button><br/>
    <br/>
    <br/>
    <button onclick="invokeNavigatorClose()">关闭</button>  <br/>
    <button onclick="invokeNavigatorReload()">刷新</button>  <br/>
    <button onclick="invokeNavigatorFoward()">前进</button>  <br/>
    <button onclick="invokeOpenUrl()">启动外部浏览器</button>  <br/>
    <button onclick="invokeOldWebview()">启动旧的通用webview</button>  <br/>
    <button onclick="invokeWebview()">启动通用webview</button>  <br/>
  
    <button onclick="invokeGoMain()">跳转到首页</button>  <br/>
    <button onclick="invokeCheckLogin()">检查登陆</button>  <br/>
    
    <a href="tel:18819272037">拨打电话</a><br/>
    <a href="mailto:gukeming@ds.cn">发送邮件</a><br/>

      
    <br/>
    <br/>
    <a href="index1.html?routeName=Map&url=http://www.baidu.com&needLogin=true&a=true&b='123'&c='12.6f'&d=12.7d">跳转测试原生</a><br/>
    
    <br/>
    <a href="index1.html?a=1&b=xxx&c={a:1}">跳转测试</a>

    <br/>
    <a href="http://debugx5.qq.com/">跳转测试</a>
    <p>
      <img class="img" width="500" height="500" id="previewimg">
  </p>
    <input class="select" type="file" accept="image/*" id="picfile" name="选择">
  </body>

  <script>
      jDsSdk.config({
        debug: true,
        setting: {
          title: "大圣科技",
          fitsStatusBar: true,
          autoReolad: false,
          shareWeb: {
            url: 'https://www.baidu.com',
            title: "baidu",
            thumb: "https://www.baidu.com/img/pc_cc75653cd975aea6d4ba1f59b3697455.png",
            desc: "分享测试",
            channels: ['FRIEND', 'WEIXIN'],
            extra: {
              id: 1,
              xx: "123456"
            },
          },
        }
      });

      jDsSdk.setResInterceptor(function(res, req) {
        if (res && (res.code === "2" || res.code === "3")) {
          alert('不支持该方法，请升级app');
          return;
        }
        return res;
      });

      function invokeTest() {
        jDsSdk.invoke("device.testMethod", {
          age: 10086,
          name: "gukeming"
        }, function(result) {
          console.log("调用结果", JSON.stringify(result));
          alert("调用结果" + JSON.stringify(result));
        });
      }

      function invokeShareWeb1() {
        jDsSdk.invoke("share.shareWeb", {
          url: 'https://www.baidu.com',
          title: "baidu",
          thumb: "https://www.baidu.com/img/pc_cc75653cd975aea6d4ba1f59b3697455.png",
          desc: "分享测试",
          channels: ['FRIEND', 'WEIXIN'],
          extra: {
            id: 1,
            xx: "123456"
          },
        }, function(result) {
          
        });
      }

      function invokeShareWeb2() {
        var shareInfo =  {
            url: 'https://www.baidu.com',
            title: "baidu",
            thumb: "https://www.baidu.com/img/pc_cc75653cd975aea6d4ba1f59b3697455.png",
            desc: "分享测试",
            channels: ['FRIEND', 'WEIXIN'],
            extra: {
              id: 1,
              xx: "123456"
            },
          }
          
        var wxShare = Object.assign({}, shareInfo, {
          title: "wxtitle",
          desc: "wx分享测试",
        });

        var wbShare = Object.assign({}, shareInfo, {
          title: "wbtitle",
          desc: "wb分享测试",
        });

        var gxShare = Object.assign({}, shareInfo, {
          title: "gxtitle",
          desc: "gx分享测试",
        });

        jDsSdk.invoke("share.shareWebWithChannel", {
          WEIXIN: wxShare,
          WEIXIN_CIRCLE: wxShare,
          SINA: wbShare,
          FRIEND: gxShare,
          GROUP: gxShare,
        }, function(result) {
          
        });
      }

      

      function invokeShareImage1() {
        jDsSdk.invoke("share.shareImage", {
          imgUrl: "https://www.baidu.com/img/pc_cc75653cd975aea6d4ba1f59b3697455.png",
        }, function(result) {
          
        });
      }

      function invokeNavigatorClose() {
        jDsSdk.invoke("navigator.close");
      }

      function invokeNavigatorReload() {
        jDsSdk.invoke("navigator.reload");
      }

      function invokeNavigatorFoward() {
        jDsSdk.invoke('navigator.goBackOrForward',{
          step: 1
        });
      }

      function invokeOpenUrl() {
        jDsSdk.invoke('navigator.openUrl',{
          url: "http://www.baidu.com"
        }, function(res){

        });
      }

      function invokeOldWebview() {
        jDsSdk.invoke('router.goOWebview', {
          url: 'http://10.8.91.138:3000',
          showTitle: 'test',
          fitsStatusBar: false
        })

      }

      function invokeWebview() {
        jDsSdk.invoke('router.goWebview', {
          url: 'http://10.8.91.138:3000',
        })

      }

      function invokeCheckLogin() {
        jDsSdk.invoke('router.isLogin', {}, function(res){
          if(res.data) {
            alert('已经登陆')
          } else {
            alert('未登陆')
          }
        })

      }

      function invokeGoMain() {
        jDsSdk.invoke('router.goMain', {position: 2})

      }

      function getQueryParams() {
        var params = jDsSdk.getQueryParams();
        alert(JSON.stringify(params));
      }
      
      //原生调用
      jDsSdk.addNativeCallback("methodName", function(channel) {
          
      });

      //图片选择
      document.querySelector('.select').addEventListener('change', function(e){
        var URL = window.URL || window.webkitURL;
          document.getElementById('previewimg').src = URL.createObjectURL(this.files[0]);
      });

      
      jDsSdk.onReady(function(){
        //alert(jDsSdk.getAppVersion())
        
        alert(jDsSdk.getAppParam('token'))
      })
  </script>
</html>

